﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserDetail.aspx.cs" Inherits="admin_system_UserDetail" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="/Admin/Css/Common.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jQuery1.7.js" type="text/javascript"></script>
    <script src="/Plugin/artDialog/jquery.artDialog.source.js?skin=blue" type="text/javascript"></script>
    <script src="/Plugin/artDialog/iframeTools.source.js" type="text/javascript"></script>
    <script src="/Plugin/Validform/js/Validform_v4.0.js" type="text/javascript"></script>
    <link href="/Plugin/Validform/css/style.css" rel="stylesheet" type="text/css" />
    <%--<script src="/Scripts/MyCommon.js" type="text/javascript"></script>--%>
    <script src="/Scripts/sjn.1.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">

        var win = art.dialog.open.origin;
        
        //页面加载
        $(function () {

            //初始化表单提交
            $(".registerform").Validform({
                tiptype: 2,
                postonce: true,
                ajaxPost: true,
                callback: function (data) {
                    if (data.status == "y") {
                        art.artDialog.alert(data.info);
                        win.$('#UserList').datagrid("reload");
                        art.dialog.close();
                    } else {
                        art.artDialog.alert(data.info);
                    }
                }
            });

            //当页面为编辑页面时，不对用户名进行验证
            if (myurl().attr("act") == "edit") {
                $("#Account")
                    .removeAttr("ajaxurl")
                    .attr("disabled", true)
                    .attr("readonly", true);
            }


            //页面加载完成后，给角色列表中，添加删除事件
            $("#roles_list span img").live("click", function () {
                var span = $(this).parents("span");
                var name = $.trim(span.text());
                var id = span.attr("id");
                span.remove();
                var rolesids = $("#rolesId").val();
                $("#rolesId").val(rolesids.replace(id + ",", "").replace("," + id, "").replace(id, ""));
            });

            var editData = art.dialog.data("editData");
            if (editData != null && editData != undefined) {
                $("#Account").val(editData.Account);
                $("#Email").val(editData.Email);
                $("#UserName").val(editData.UserName);
                $("#IsDisabled").val(editData.IsDisabled.toString());
                $("#Password").val("密密密密密密");
                $("#UserID").val(editData.UserID);
            }


        });


        //添加所属角色
        var AlertRoles = function () {
            //var SpanTem = $("<span><img src=\"/admin/images/11.gif\" alt=\"删除角色\" /></span>");

            //获取当前用户所拥有的角色,传给角色列表页，用于显示当前用户拥有了哪些角色
            art.dialog.removeData("oldRoles"); //先清空存储器
            art.dialog.data("oldRoles", $("#rolesId").val());

            //弹出角色列表框
            art.dialog.open('<%=MyUrl.ToAb("~/") %>Admin/Dialog/AlertRole.aspx',
                            {
                                title: "添加所属角色",
                                id: 'AddAlertRole',
                                lock: true,
                                height: "auto",
                                close: function () {
                                    var newRoles = art.dialog.data("newRoles");  //获取从角色列表中选中的角色
                                    var ids = [];
                                    $("#roles_list").empty();

                                    $(newRoles).each(function (i, item) {
                                        $("#roles_list").append('<span id="' + item.id + '">' + item.name + '&nbsp;<img src="/admin/images/11.gif" alt="删除角色" /></span>');
                                        ids.push(item.id);
                                    });

                                    $("#rolesId").val(ids.join(","));  //把新的角色ID放入到隐域中
                                    art.dialog.resetSize();
                                }
                            });
        }


    </script>
    <style type="text/css">
        #roles_list
        {
            line-height: 20px;
        }
        #roles_list span
        {
            margin-right: 30px;
            display: inline-block;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <form id="form1" class="registerform" runat="server">
    <div style="margin: 10px; background-color: #F8F8F8; border: 1px solid #ccc; border-radius: 4px 4px 4px 4px;
        padding: 10px;">
        <div style="font-weight: bold; font-size: 14px;">
            基本信息</div>
        <table width="540">
            <tr>
                <td style="width: 60px;">
                    <span style="color: Red">*&nbsp;</span>用户名：
                </td>
                <td style="width: 130px;">
                    <input type="text"  id="Account" name="Account" class="inputxt" ajaxurl="UserDetail.aspx?act=checkingName"
                        datatype="*1-40" nullmsg="填写用户名，用户于系统登录账户。" errormsg="长度为1~40，请输入正确的字符串长度" />
                </td>
                <td>
                    <div class="Validform_checktip">
                        填写用户名，用户于系统登录账户。
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <span style="color: Red">*&nbsp;</span>密&nbsp;&nbsp;&nbsp;码：
                </td>
                <td>
                    <input type="password" id="Password" name="Password" class="inputxt" datatype="*6-20"
                        nullmsg="请填写登录密码。" errormsg="长度为6~20，请输入正确的字符串长度" />
                </td>
                <td>
                    <div class="Validform_checktip">
                        请填写登录密码。
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <span style="color: Red">*&nbsp;</span>邮&nbsp;&nbsp;&nbsp;箱：
                </td>
                <td>
                    <input type="text" id="Email" name="Email" class="inputxt" datatype="e" nullmsg="请填写邮箱。"
                        errormsg="请输入合法邮箱，长度不可超过50个字符。" />
                </td>
                <td>
                    <div class="Validform_checktip">
                        请填写邮箱。
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <span style="color: Red">*&nbsp;</span>姓&nbsp;&nbsp;&nbsp;名：
                </td>
                <td>
                    <input type="text" id="UserName" name="UserName" class="inputxt" datatype="*1-20"
                        nullmsg="请填写真实姓名。" errormsg="长度为1~20，请输入正确的字符串长度" />
                </td>
                <td>
                    <div class="Validform_checktip">
                        请填写真实姓名。
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <span style="color: Red">*&nbsp;</span>状&nbsp;&nbsp;&nbsp;态：
                </td>
                <td>
                    <select id="IsDisabled" name="IsDisabled">
                        <option value="true">开启</option>
                        <option value="false">禁用</option>
                    </select>
                </td>
                <td>
                </td>
            </tr>
        </table>
    </div>
    <div style="margin: 10px; background-color: #F8F8F8; border: 1px solid #ccc; border-radius: 4px 4px 4px 4px;
        padding: 10px;">
        <div style="font-weight: bold; font-size: 14px;">
            所属角色</div>
        <div id="roles_list">
            <asp:Repeater ID="rp_rolesList" runat="server">
                <ItemTemplate>
                    <span id="<%#Eval("RoleID")%>">
                        <%#Eval("RoleName")%>&nbsp;<img src="/admin/images/11.gif" alt="删除角色" /></span>
                </ItemTemplate>
            </asp:Repeater>
        </div>
    </div>
    <div class="aui_buttons" style="height: 35px;">
        <input type="hidden" id="rolesId" name="rolesId" value="<%=rolesids %>" />
        <button id="c_ok" class="aui_state_highlight" type="submit" style="float: right;">
            <%=btn_text %>
        </button>
        <button id="Button1" type="button" class="aui_state_highlight" onclick="AlertRoles()"
            style="float: right;">
            添加所属角色
        </button>
        <asp:HiddenField ID="action" runat="server" />
        <input type="hidden" id="UserID" name="UserID" value="" />
    </div>
    <asp:Label ID="lb_js" runat="server"></asp:Label>
    </form>
</body>
</html>
